package com.hxzy.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.RequestHandler;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

import java.util.ArrayList;

@Configuration
@EnableSwagger2
public class SwaggerConfig {
    //配置了Swagger的Docter的bean实例
    @Bean
    public Docket docket1(){
        return new Docket(DocumentationType.SWAGGER_2)
                .groupName("梁鑫")
                .apiInfo(apiInfo1())
                //选择接口
                .select()
                //选择接口
                .apis(RequestHandlerSelectors.basePackage("com.hxzy.course.controller"))
                //build()一般表示工厂设计模式
                .build();
    }
    @Bean
    public Docket docket2(){
        return new Docket(DocumentationType.SWAGGER_2)
                .groupName("贺景深")
                .apiInfo(apiInfo2())
                //选择接口
                .select()
                //选择接口
                .apis(RequestHandlerSelectors.basePackage("com.hxzy.booking.controller"))
                //build()一般表示工厂设计模式
                .build();
    }
    private ApiInfo apiInfo1(){
        //作者信息
        Contact contact = new Contact("梁鑫","","921506729@qq.com");
        return new ApiInfo(
                "第三阶段项目",
                "SpringBoot综合练习",
                "1.0",
                "urn:tos",
                contact,
                "Apache 2.0",
                "http://www.apache.org/licenses/LICENSE-2.0",
                new ArrayList<>());
    }
    private ApiInfo apiInfo2(){
        //作者信息
        Contact contact = new Contact("贺景深","","12435@qq.com");
        return new ApiInfo(
                "第三阶段项目",
                "SpringBoot综合练习",
                "1.0",
                "urn:tos",
                contact,
                "Apache 2.0",
                "http://www.apache.org/licenses/LICENSE-2.0",
                new ArrayList<>());
    }
}
